//
//  QConst.swift
//  爱汽车
//
//  Created by liujianlong on 2023/8/8.
//

//
//  MMConst.swift
//  EPMM
//
//  Created by liujianlong on 2022/7/27.
//

import Foundation
import UIKit
//MARK: - 获取屏幕大小
let kUIScreenSize = UIScreen.main.responds(to: #selector(getter: UIScreen.nativeBounds)) ? CGSize(width: UIScreen.main.nativeBounds.size.width / UIScreen.main.nativeScale, height: UIScreen.main.nativeBounds.size.height / UIScreen.main.nativeScale) : UIScreen.main.bounds.size
let kUIScreenWidth = kUIScreenSize.width
let kUIScreenHeight = kUIScreenSize.height
let kUIScreenBounds = UIScreen.main.bounds

//MARK: - 判断屏幕尺寸
let kSCREEN_MAX_LENGTH = max(kUIScreenWidth, kUIScreenHeight)
let kSCREEN_MIN_LENGTH = min(kUIScreenWidth, kUIScreenHeight)

//MARK: - 机型判断
let kUI_IPHONE = (UIDevice.current.userInterfaceIdiom == .phone)
let kUI_IPHONE5 = (kUI_IPHONE && kSCREEN_MAX_LENGTH == 568.0)
let kUI_IPHONE6 = (kUI_IPHONE && kSCREEN_MAX_LENGTH == 667.0)
let kUI_IPHONEPLUS = (kUI_IPHONE && kSCREEN_MAX_LENGTH == 736.0)
let kUI_IPHONEX = (kUI_IPHONE && kSCREEN_MAX_LENGTH > 780.0)
let gap : CGFloat = 10.0
//MARK: - 获取状态栏、标题栏、导航栏高度
let kUIStatusBarHeight: CGFloat = UIApplication.shared.statusBarFrame.size.height
let kUINavigationBarHeight: CGFloat =  kUI_IPHONEX ? 88 : 64
let KUITabBarHeight: CGFloat = kUI_IPHONEX ? 83 : 49
let LLBottomInset : CGFloat = isIphoneX ? 34 : 0

//navigationBarHeight默认高度44 （iPhoneX 88）
//tabBarHeight默认高度49     （iPhoneX 83）
var isIphoneX: Bool {
    guard #available(iOS 11.0, *)else {
        return false;
    }
    //是ios11以上，然后判断圆角
    var isX = false
    if #available(iOS 13.0, *) {
        isX = UIApplication.shared.keyWindow?.safeAreaInsets.bottom ?? 0 > 0.0
    }
    else{
        isX = UIApplication.shared.windows[0].safeAreaInsets.bottom > 0
    }
    return isX
}
//适配 350 375 414       568 667 736
func kAutoLayoutWidth(_ width: CGFloat) -> CGFloat {
    return width*kUIScreenWidth / 375
}
func kAutoLayoutHeigth(_ height: CGFloat) -> CGFloat {
    return height*kUIScreenHeight / 667
}
let BLEDIS = "蓝牙出问题了，快去检查一下吧～"
var DialEditedenable = false
let LocalCustomArrayKey = "LocalCustomArrayKey"
let UpdateUserData = "UpdateUserData"
let updateVersion = "updateVersion"
/// 自定义表盘（大头照）65533
let DialIDCustomPhoto = 65533
/// 自定义表盘（默认）65534
let DialIDCustomDefault = 65534
//var ME = UserTool.sharedInstance().user
func LS(_ s : String)->String
{
    return NSLocalizedString(s, comment: "")
}
func MyPrint<T>(_ msg:T,file:String = #file, funcName:String = #function, lineNumber:Int = #line){
    let fileName = (file as NSString).lastPathComponent
    let formmater = DateFormatter()
    formmater.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSS"
    let time =  formmater.string(from:Date())
    print("\(fileName)(\(lineNumber))-\(time):\(msg)")
}
func HEX<T>(_ num:T)->String{
    guard let n = num as? UInt8 else{return ""}
    let str = String(format: "%.2X", n)
    return str
}
//var USER = UserInfoManager.shareDelegate()
/// 距离单位
//func distanceUnit()->String{
//    return USER.userInfoModel.isKilometreUnit ? "公里" : "英里"
//}
/// 根据单位的距离
//func KM(_ distance:CGFloat)->CGFloat{
//    return USER.userInfoModel.isKilometreUnit ? distance : distance * XLConst.KMScale
//}

/// 回调：经过一定算法，筛选后的有效值的数组，以及平均值，最大值，最小值
typealias validData = (_ array:[CGFloat], _ avg:CGFloat, _ max:CGFloat, _ min:CGFloat)->Void

///// 各种运动形式消耗的卡路里系数
//func sportK(_ type:SportType)->Float
//{
//    switch type
//    {
//    case SportTypeWalk:
//        return 0.8214
//    case SportTypeRun:
//        return 1.036
//    case SportTypeRide:
//        return 0.6142
//    default:
//        break
//    }
//    return 0
//}

//MARK: - 获取颜色/字体
///大背景色
let HEX_BG = "#ffffff".color()
/// 分割线
let HEX_LINE = "#EEEEEE".color()
///灰色 文字
let HEX_GRAY1 = "#CFCFCF".color()
/// 深灰色 文字
let HEX_GRAY2 = "#9B9B9B".color()
///黑色  主要文字标题/文字按钮
let HEX_BLACK = "#000000".color()
/// 橙色 消息提示/数据提示
let HEX_ORANGE = "#fb5620".color()
/// 黄色 消息提示/数据状态
let HEX_YELLOW = "#FFD300".color()
///绿色
let HEX_GREEN = "#00E0D3".color()
///带点灰色蒙罩的绿色
let HEX_GREEN2 = "#00C2B7".color()
///青色
let HEX_BLUE = "#005BBA".color()
/// 墨青色
let HEX_BLUE2 = "#092D74".color()
///粗字体
let FONT_B = "Oswald-Bold"
///细字体
let FONT_L = "Oswald-Light"
///常规字体
let FONT_R = "Oswald-Regular"
/// 日期/导航栏/标题
let FONT_TITLE = font(FONT_R, 16)
/// 正文
let FONT_TEXT = font(FONT_R, 14)
/// 设备提示/电量信息
let FONT_TIP = font(FONT_R, 12)


let UMKey =  "688876d079267e0210c70d94"
